package com.hm.ipay.schedule;

import com.hm.ipay.service.TransferService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 *  信用值转回余额的定时任务
 */
@Component
public class AutoSwitchBack {

    @Autowired
    TransferService transferService;

    private static final SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");


    //@Scheduled(fixedDelay = 10000)
    @Scheduled(cron="0 1 3 * * ?")  // 每天 凌晨3点零1分执行
    public void reportCurrentTime() {
        System.out.println("AutoSwitchBack 现在时间：" + dateFormat.format(new Date()));
        transferService.autoSwitchBack();
    }
}
